module.exports = class extends think.Logic {
  indexAction (o) {
    const method = this.ctx.method.toLowerCase()
    this[`${method}Action`] && this[`${method}Action`]()
  }
  getAction () {
    this.allowMethods = 'GET'
    this.rules = {
      page: {required: false, int: true, default: 1},
      pageSize: {required: false, int: true, default: 20},
      // where: {required: false, object: true, default: {}},
      order: {required: false, object: true, default: {_id: -1}},
      id: {required: false, trim: true, ObjectId: true},
      first: {required: false, trim: true, default: ''},
      last: {required: false, trim: true, default: ''}
    }
  }
  postAction () {
    this.allowMethods = 'POST'
    this.rules = {
      id: {required: false, trim: true}
    }
  }
  deleteAction () {
    this.allowMethods = 'DELETE'
    this.rules = {
      id: {required: false, trim: true},
      where: {required: false, object: true, default: {}}
    }
  }
  putAction () {
    this.allowMethods = 'PUT'
    this.rules = {
      id: {required: false, trim: true},
      where: {required: false, object: true, default: {}}
    }
  }
}
